<?php
namespace encrypt;

/*
 * 官网api加密类文件
 * */
class Encrypt
{
        const secretKey='sdfkjhrtlbd43f85';
        const iv='zdskrt857j1cjksp';
    //加密函数
    public static function encrypt($str){
        $str = json_encode($str);
        $encrypt_str=openssl_encrypt($str,"AES-128-CBC", self::secretKey,OPENSSL_RAW_DATA, self::iv);
        return base64_encode($encrypt_str);
    }

    //解密函数
    public static function decrypt($str){
        $decrypt = openssl_decrypt(base64_decode($str),"AES-128-CBC",self::secretKey,OPENSSL_RAW_DATA,self::iv);
        return json_decode($decrypt,true);
    }


}